<template>
  <div class="permission-management flex">
    <!-- 空间 -->
    <toolbox class="permission-management-toolbox shrink-0"></toolbox>
    <!--  -->
    <div class="permission-management-wrapper flex-1">
      <div v-for="item in data" :key="item.id" class="list">
        <div class="list-title">{{ item.name }}</div>
        <div class="list-content">
          <div class="list-item">
            <div><el-icon><Plus /></el-icon></div>
            <div>添加成员</div>
          </div>
          <div class="list-item" v-for="val in item.children" :key="val.id">
            <div class="list-item-content">
              <div class="avatar"></div>
              <div class="email">{{ val.email }}</div>
              <div class="name">{{ val.name }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import toolbox from '../components/toolbox.vue'
import { Plus } from '@element-plus/icons-vue'

const data = ref([
  { 
    name: '管理者', 
    id: 1,
    children: [
      { name: 'aaaaa', email: '1111@qq.com', id: 1 },
      { name: 'bbbbb', email: '1111@qq.com', id: 2 },
      { name: 'ddddd', email: '1111@qq.com', id: 3 },
    ] 
  },
  {
    name: '开发者',
    id: 2,
    children: [
      { name: 'aaaaa', email: '1111@qq.com', id: 1 },
      { name: 'bbbbb', email: '1111@qq.com', id: 2 },
      { name: 'ddddd', email: '1111@qq.com', id: 3 },
    ]
  },
  {
    name: '浏览者',
    id: 3,
    children: [
      { name: 'aaaaa', email: '1111@qq.com', id: 1 },
      { name: 'bbbbb', email: '1111@qq.com', id: 2 },
      { name: 'ddddd', email: '1111@qq.com', id: 3 },
    ]
  },
])

onMounted(async () => {

})

</script>

<style lang="scss" scoped>
.permission-management {
  height: 100%;
  .permission-management-toolbox{
    width: 180px;
    border-right: 1px solid #333;
  }
  .permission-management-wrapper{
    padding: 15px;
    .list {
      overflow: hidden;
      .list-title {
        padding: 12px 16px;
        padding-bottom: 0;;
        font-weight: 600;
        font-size: 14px;
      }
      .list-content {
        padding: 12px;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
      }
      .list-item {
        flex: 0 0 120px; // 固定宽度
        height: 120px;
        border: 1px solid #d1d5db;
        background-color: #222;
        border-radius: 4px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
        &:hover {
          border-color: #409eff;
        }
        .list-item-content {
          display: flex;
          flex-direction: column;
          align-items: center;
          gap: 6px;
          .avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: #e5e7eb;
          }
          .email {
            font-size: 12px;
            color: #6b7280;
            word-break: break-all;
            text-align: center;
          }
          .name {
            font-size: 13px;
            font-weight: 500;
            color: #6b7280;
          }
        }
      }
    }
  }
}

</style>
